package Hot100;

import common.TreeNode;

/**
 * @author zhangmin
 * @create 2021-12-26 15:11
 */
public class isSymmetric101 {
    /**101. 对称二叉树
     * 给定一个二叉树，检查它是否是镜像对称的。
     * 判断左右子树是否镜像对称，root.left.left==root.right.right&&root.left.right==root.right.left
     * */
    boolean isSymmetric(TreeNode left,TreeNode right){
        if (left==null&&right==null) return true;
        if (left==null||right==null||left.val!=right.val) return false;
        return isSymmetric(left.left,right.right)&&isSymmetric(left.right,right.left);
    }
    public boolean isSymmetric(TreeNode root) {
        if (root==null) return true;
        return isSymmetric(root.left,root.right);
    }
}
